<template>
  <div class="container">
    <vxe-toolbar
      id="warehouseLocationId"
      :custom="{ storage: true }"
      export
      :refresh="{query: findList}"
    >
      <template v-slot:buttons>
        <div>
          <el-button @click="findList">查询</el-button>
          <el-button :disabled="getWaybillNumBtn" @click="gainWaybill">获取运单号</el-button>
          <el-button :loading="updateStatusloading" @click="updateStatus">更新状态</el-button>
          <el-button :disabled="getWaybillNumBtn" @click="changeCarrier">更改承运商</el-button>
        </div>
      </template>
    </vxe-toolbar>
      <!-- <el-button :disabled="printFlag && generatePicking" @click="generate">获取运单号</el-button> -->
    <vxe-table
      ref="xTable"
      border
      resizable
      stripe
      highlight-current-row
      :export-config='{type:"csv"}'
      show-footer
      highlight-hover-row
      row-id="id"
      :loading="loading"
      class="mytable-footer"
      height="640"
      align="center"
      :data="tableData"
      :edit-config="{ trigger: 'click', mode: 'row', showStatus: true }"
      :sort-config="{ remote: true }"
      @sort-change="sortField"
      @checkbox-all="checkboxChangeEvent"
      @checkbox-change="checkboxChangeEvent"
      :seq-config="{startIndex: listQuery.pageNum * listQuery.pageSize - listQuery.pageSize}"
    >
      <vxe-table-column type="seq" width="60"></vxe-table-column>
      <vxe-table-column type="checkbox" width="60"></vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="status"
          title="状态"
          min-width="150"
          sortable
          :formatter="formatterStatus"
        />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.status" placeholder="请选择" clearable>
            <el-option
              v-for="item in statusList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="taskStatus"
          title="任务状态"
          min-width="150"
          sortable
          :formatter="({ cellValue }) => getEnumsOrDict('dict', taskStatusList, ['value', 'label']).get(cellValue)"
        />
        <template #header>
          <el-select v-model="listQuery.taskStatus" placeholder="请选择" clearable>
            <el-option
              v-for="item in taskStatusList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="sourceType"
          title="数据来源"
          min-width="150"
          sortable
          :formatter="formatterSource"
        />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.sourceType" placeholder="请选择" clearable>
            <el-option
              v-for="item in sourceList"
              :key="item.code"
              :label="item.message"
              :value="item.code"
            ></el-option>
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="prepackaged"
          title="是否预打包"
          min-width="150"
          sortable
          :formatter="formatterPack"
        />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.prepackaged" placeholder="请选择" clearable>
            <el-option
              v-for="item in prepackagedList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="warehouseName" title="仓库" min-width="150" />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.warehouseCode" placeholder="请选择仓库 " style="width:100%" clearable>
            <el-option
              v-for="item in warehouseData"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="shipmentName"
          title="入驻商"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.shipmentName" clearable filterable placeholder="入驻商">
            <el-option
              v-for="item in options"
              :key="item.partyCode"
              :label="item.userName"
              :value="item.userName">
            </el-option>
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="carrierName"
          title="承运商"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.carrierName" clearable filterable placeholder="承运商">
            <el-option
              v-for="item in carrierList"
              :key="item.code"
              :label="item.name"
              :value="item.name">
            </el-option>
          </el-select>
        </template>
      </vxe-table-column>
      <!-- <vxe-table-column>
        <vxe-table-column
          field="sourcePlatformName"
          title="销售平台"
          min-width="150"
          sortable
        />
        <template #header>
          <el-select v-model="listQuery.sourcePlatformCode" clearable filterable placeholder="销售平台">
            <el-option v-for="item in salePlatformList" :key="item.code" :label="item.name" :value="item.code" />
          </el-select>
        </template>
      </vxe-table-column> -->
      <vxe-table-column>
        <vxe-table-column
          field="sourcePlatformCode"
          title="销售平台"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.sourcePlatformCode" placeholder="销售平台" clearable />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="shopNick"
          title="店铺"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.shopNick" placeholder="店铺" clearable />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="wavePickingCode"
          title="波次号"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.wavePickingCode"
            placeholder="波次号"
            clearable
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="code"
          title="订单号"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.code" placeholder="订单号" clearable />
        </template>
      </vxe-table-column>
       <vxe-table-column>
        <vxe-table-column field="orderTag" title="订单标识" min-width="150" />
        <template v-slot:header="{ column }">
          <!-- goodsSortQuantity -->
          <el-select v-model="listQuery.orderTag" placeholder="请选择订单标识 " style="width:100%" clearable>
            <el-option
              v-for="item in orderData"
              :key="item.orderTag"
              :label="item.orderTag"
              :value="item.orderTag"
            />
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="sourceCode"
          title="来源单号"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.sourceCode"
            placeholder="来源单号"
            clearable
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="isvCode"
          title="原始单号"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.isvCode"
            placeholder="原始单号"
            clearable
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="type" title="单据类型" min-width="200" :formatter="formatterType" />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.type" placeholder="请选择单据类型" clearable>
            <el-option
              v-for="item in typeList"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column
        field="waybillCode"
        title="运单号"
        min-width="200"
        show-overflow
      />
      <vxe-table-column>
        <vxe-table-column
          field="goodsSortQuantity"
          title="种数"
          min-width="300"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.goodsSortQuantityStart"
            placeholder="下限"
            clearable
            style="width: 45%"
          />
          -
          <el-input
            v-model="listQuery.goodsSortQuantityEnd"
            placeholder="上限"
            clearable
            style="width: 45%"
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="totalNum"
          title="件数"
          min-width="300"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.totalNumStart"
            placeholder="下限"
            clearable
            style="width: 45%"
          />
          -
          <el-input
            v-model="listQuery.totalNumEnd"
            placeholder="上限"
            clearable
            style="width: 45%"
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="distributionNum"
          title="分配数量"
          min-width="300"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.distributionNumStart"
            placeholder="下限"
            clearable
            style="width: 45%"
          />
          -
          <el-input
            v-model="listQuery.distributionNumEnd"
            placeholder="上限"
            clearable
            style="width: 45%"
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="weight"
          title="重量"
          min-width="300"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.weightStart"
            placeholder="下限"
            clearable
            style="width: 45%"
          />
          -
          <el-input
            v-model="listQuery.weightEnd"
            placeholder="上限"
            clearable
            style="width: 45%"
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="volume"
          title="体积"
          min-width="300"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.volumeStart"
            placeholder="下限"
            clearable
            type="number"
            style="width: 45%"
          />
          -
          <el-input
            v-model="listQuery.volumeEnd"
            placeholder="上限"
            clearable
            type="number"
            style="width: 45%"
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="money" title="金额" min-width="300" sortable />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.moneyStart"
            placeholder="下限"
            clearable
            type="number"
            style="width: 45%"
          />
          -
          <el-input
            v-model="listQuery.moneyEnd"
            placeholder="上限"
            clearable
            type="number"
            style="width: 45%"
          />
        </template>
      </vxe-table-column>
       <vxe-table-column>
        <vxe-table-column
          field="receiverName"
          title="收货人"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.receiverName"
            placeholder="收货人"
            clearable
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="receiverMobile"
          title="收货人电话"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.receiverMobile"
            placeholder="收货人电话"
            clearable
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="receiverProvince" title="省份" min-width="150" sortable/>
        <template #header>
          <el-input v-model="listQuery.receiverProvince" placeholder="请输入省份" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="receiverCity" title="城市" min-width="150" sortable/>
        <template #header>
          <el-input v-model="listQuery.receiverCity" placeholder="请输入城市" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="receiverDistrict" title="区县" min-width="150" sortable/>
        <template #header>
          <el-input v-model="listQuery.receiverDistrict" placeholder="请输入区县" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="receiverDetailAddress"
          show-overflow
          title="收货人地址"
          min-width="700"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.receiverDetailAddress"
            placeholder="收货人地址"
            clearable
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="gmtCreated"
          show-header-overflow
          show-overflow
          title="接收时间"
          min-width="420"
          sortable
          :resizable="false"
        />
        <template v-slot:header>
          <el-date-picker
            v-model="gmtCreatedRange"
            type="datetimerange"
            value-format="yyyy-MM-dd HH:mm:ss"
            :picker-options="pickerOptions"
            style="width: 100%"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="(value) => changeDate(value, 'gmtCreated')"
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="remarks"
          title="备注"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input
            v-model="listQuery.remarks"
            placeholder="请输入备注"
            clearable
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="failureReasonOfGettingWaybill"
          title="失败原因"
          min-width="200"
          sortable
        />
        <template #header>
          <el-input
            v-model="listQuery.failureReasonOfGettingWaybill"
            placeholder="请输入失败原因"
            clearable
          />
        </template>
      </vxe-table-column>
      <!-- <vxe-table-column field="failureReasonOfGettingWaybill" title="失败原因" min-width="200" show-overflow /> -->
      <vxe-table-column title="操作" fixed="right" width="60">
        <template slot-scope="scope">
          <el-tooltip  effect="dark" content="查看" placement="top">
            <vxe-button
              type="text"
              @click="modelShowHide(scope.row.code)"
            >
              <i class="el-icon-document" />
            </vxe-button>
          </el-tooltip>
        </template>
      </vxe-table-column>
    </vxe-table>
    <vxe-modal
      v-model="operationModel"
      title="查看"
      width="78%"
      height="650"
      destroy-on-close
    >
      <compEdit
        :operationCode="operationCode"
        @operationComplete="
          modelShowHide();
          findList();
        "
      />
    </vxe-modal>
    <vxe-modal
      v-model="changeCarrierModel"
      title="更改承运商"
      min-height="200"
      destroy-on-close
    >
      <changeCarrier
        :visible.sync="changeCarrierModel"
        :changeCarrierData="changeCarrierData"
        @refresh="findList"
      />
    </vxe-modal>
    <!-- <vxe-pager
      :current-page.sync="listQuery.pageNum"
      :page-size.sync="listQuery.pageSize"
      :total="listQuery.total"
      :layouts="[
        'PrevJump',
        'PrevPage',
        'Number',
        'NextPage',
        'NextJump',
        'Sizes',
        'FullJump',
        'Total',
      ]"
      :page-sizes="[10, 15, 20, 50, 100]"
      @page-change="handlePageChange"
    /> -->
  <pagination :listQuery.sync="listQuery" @page-change="handlePageChange" />
  </div>
</template>

<script>
import Vue from 'vue'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
import XEUtils from 'xe-utils'
import VXEUtils from 'vxe-utils'
Vue.use(VXETable, VXEUtils, XEUtils, { mounts: ['cookie'] })
import pagination from '@/views/components/pagination'
import changeCarrier from "@/views/outStorage/orderProcessing/components/changeCarrier.vue";
import compEdit from "./components/abnormalDetail.vue";
import { getWarehouse } from '@/api/basicInfo'
import { abnormalList, getEnumList, batchGetWaybillCode, shipments, carrierDropdown, updateStatus } from "@/api/outStorage";
export default {
  name: "异常订单",
  components: {
    pagination,
    changeCarrier,
    compEdit
  },
  data() {
    return {
      initFinishFlag: false, //生成波次按钮
      disabled: true, //打印运单按钮
      getWaybillNumBtn: true, // 获取运单号按钮
      tableData: [],
      // 状态
      statusList: [
        { value: '0', label: '新增' },
        { value: '1', label: '待分配' },
        { value: '2', label: '部分分配' },
        { value: '3', label: '已分配' },
        { value: '6', label: '待拣货' },
        { value: '7', label: '待复核' },
        { value: '8', label: '复核中' },
        { value: '9', label: '待出库' },
        { value: '11', label: '出库完成' },
        { value: '12', label: '拣货中' },
        { value: '13', label: '拣货完成' }
      ],
      orderData:[
        {orderTag:'单品'},
        {orderTag:'多品'},
      ],
      gmtCreatedRange:'',
      sourceList: [],
      taskStatusList: [
        { value: '1', label: '未执行' },
        { value: '2', label: '执行中' },
        { value: '3', label: '执行完成' }
      ],
      warehouseData:[],
      typeList: [
        { code: '0', name: '销售出库' },
        { code: '1', name: '报损出库' },
        { code: '2', name: '领用出库' },
        { code: '3', name: '盘亏出库' },
        { code: '4', name: '采购退货' },
        { code: '5', name: '调拨出库' },
      ],
      loading: false,
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      checked: false,
      listQuery: {
        code: this.$route.query.code,
        gmtCreated: '',
        status: '3',
        sourceType: '',
        shopNick:'',
        warehouseName: '',
        shipmentName: '',
        wavePickingCode: '',
        isvCode: '',
        sourceCode:'',
        goodsSortQuantityStart:'',
        volumeStart:'',
        volumeEnd:'',
        waybillCode:'',
        type:'',
        carrierName:'',
        total: 0,
        pageNum: 1,
        pageSize: 10,
        goodCodes:'',
        goodsNums:'',
        normalGoodCodes: "",
        sourcePlatformName:'',
        warehouseCode: this.$store.getters.authorizeDataCode
      },
      modelDetailFlag: false,
      operationModel: false,
      operationCode:'',
      wavePickingModel: false,
      wavePickingCodes: "",
      maximum: "", //最大
      numberValidateForm: {
        maxNum: "",
      },
      getEnum:{
        type: 'com.arpa.wms.domain.enums.DeliverySourceTypeEnum'
      },
      waveCodeList:[],
      parcelType: '', // 哪家快递
      printData: [], // 要打印的运单数据
      printExpressBillmodel: false, //打印机组件
      commodityModel: false, //商品查询
      explosiveModel: false, //
      options: [],
      carrierList: [],
      prepackagedList: [
        { value: '0', label: '否' },
        { value: '1', label: '是' }
      ],
      updateStatusloading: false,
      changeCarrierModel: false,
      changeCarrierData: {},
      needLoadList: false, // 在keep-live钩子函数activated内是否需要加载列表
    };
  },
  computed: {
    'printFlag': function() {
      if(this.initFinishFlag) {
        let selectRecords = this.$refs.xTable.getCheckboxRecords();
        if(selectRecords.length > 0) {
          this.disabled = false
          let stateShow = false
          for (let i = 0; i < selectRecords.length; i++) {
            if (selectRecords[i].status != '3') {
              stateShow = true
              break
            }
          }
          return stateShow
        } else {
          this.disabled = true
          return true;
        }
      }
      return true;
    }
  },
  created() {
    this.findList();
    this.getWarehouse();
    getEnumList(this.getEnum).then((response) => {
      this.sourceList = response.data
    })
  },
  activated() {
    const { meta: { noCache } } = this.$route
    if (!noCache && this.needLoadList) this.findList()
  },
  methods: {
    // 排序
    sortField({ column, property, order }) {
      if (order) {
        this.listQuery.sortField = property;
        this.listQuery.sortType = order;
      } else {
        this.listQuery.sortField = "";
      }
      this.findList();
    },
    // 查询
    findList() {
      this.loading = true
      this.getWaybillNumBtn = true
      shipments().then(res => {
        this.options = res.data
      })
      carrierDropdown().then(res => {
        this.carrierList = res.data
      })
      return new Promise(resolve=>{
        abnormalList(this.listQuery).then(res => {
          if(res.status === 0){
            this.tableData = res.data.records
            for (let i = 0; i < this.tableData.length; i++) {
              this.tableData[i].receiverDetailAddress = this.tableData[i].receiverDetailAddress
            }
            this.listQuery.total = res.data.sumObject.total;
            this.statusList.value = ''
            this.initFinishFlag = true;
          }
        }).finally(() => {
          this.loading = false
          this.needLoadList = true
        })
        resolve()
      })
    },
    // 全选与否、部分勾选与否
    checkboxChangeEvent({selection}) {
      // 已作废的单子不能获取运单号
      if (selection.length === 0) {
        this.getWaybillNumBtn = true
      } else {
        const invalid = selection.filter(item => {return item.status === '4'})
        this.getWaybillNumBtn = invalid.length > 0
      }
    },
    // 获取运单号
    gainWaybill(){
      let selectRecords = this.$refs.xTable.getCheckboxRecords()
      let arr = []
      if(selectRecords.length === 0){
        this.$message.error("请选择要获取运单的数据!");
        return
      }
      const rLoading = this.openLoading({
        text: '获取中...',
        duration: 'n'
      })
      selectRecords.forEach((i) => {
        if (i.code && i.code !== '') {
          arr.push(i.code);
        }
      });
        batchGetWaybillCode(arr).then(res => {
          if(res.status === 0){
            this.$message.success(res.msg)
          }
        }).finally(() => {
          this.findList()
          rLoading.close()
          this.$refs.xTable.clearCheckboxRow()
        })
    },
    // 更新状态
    updateStatus() {
      this.updateStatusloading = true
      updateStatus().then(res => {
          this.$message.success(res.msg)
        }).finally(() => {
          this.findList()
          this.updateStatusloading = false
          this.$refs.xTable.clearCheckboxRow()
        })
    },
    changeCarrier() {
      const selectRecords = this.$refs.xTable.getCheckboxRecords()
      const shipmentCode = selectRecords[0].shipmentCode
      if (selectRecords.every((item) => item.shipmentCode === shipmentCode)) {
        this.changeCarrierData = {
          shipmentCode,
          carrierCode: selectRecords[0].carrierCode,
          deliveryCodes: selectRecords.map(item => item.code)
        }
        this.changeCarrierModel = true
      } else {
        this.$message.warning('选择的入驻商必须相同！')
      }
    },
    changeDate(value, prefix) {
      if (value) {
        this.listQuery[`${prefix}Start`] = value[0]
        this.listQuery[`${prefix}End`] = value[1]
      } else {
        this.listQuery[`${prefix}Start`] = ''
        this.listQuery[`${prefix}End`] = ''
      }
    },
    reset() {
        this.listQuery.gmtCreated = ''
        this.listQuery.status = ''
        this.listQuery.sourceType = ''
        this.listQuery.shopNick = ''
        this.listQuery.warehouseName = ''
        this.listQuery.shipmentName = ''
        this.listQuery.wavePickingCode = ''
        this.listQuery.isvCode = ''
        this.listQuery.deliveryOrderCode =''
        this.listQuery.waybillCode =''
        this.listQuery.type = ''
        this.listQuery.carrierName = ''
        this.listQuery.total = 0
        this.listQuery.pageNum = 1
        this.listQuery.goodCodes = ''
        this.listQuery.goodsNums = ''
    },
    // 分页handle
    handlePageChange({ currentPage, pageSize }) {
      this.listQuery.pageNum = currentPage;
      this.listQuery.pageSize = pageSize;
      this.findList();
    },
    // 查看
    modelShowHide(code) {
      this.operationModel = !this.operationModel;
      if (code) {
        this.operationCode = code;
      }
    },
    //仓库查询
    getWarehouse(){
      getWarehouse().then(response => {
        this.warehouseData = response.data
        this.warehouseCode = this.warehouseData[0].code
        this.initFinishFlag = true;
      })
    },
    formatterPack({ cellValue }) {
      if (cellValue == '0') {
        return '否'
      }
      if (cellValue == '1') {
        return '是'
      }
    },
    // 状态
    formatterStatus({ cellValue }) {
      // return this.statusList[cellValue].label;
      if (cellValue == '0') {
          return '新增'
        }
        if (cellValue == '1') {
          return '待分配'
        }
        if (cellValue == '2') {
          return '部分分配'
        }
        if (cellValue == '3') {
          return '已分配'
        }
        if (cellValue == '4') {
          return '已作废'
        }
         if (cellValue == '5') {
          return '生成波次中'
        }
        if (cellValue == '6') {
          return '待拣货'
        }
        if (cellValue == '7') {
          return '待复核'
        }
        if (cellValue == '8') {
          return '复核中'
        }
        if (cellValue == '9') {
          return '待出库'
        }
        if (cellValue == '11') {
          return '出库完成'
        }
        if (cellValue == '12') {
          return '拣货中'
        }
        if (cellValue == '13') {
          return '拣货完成'
        }
    },
    //
    formatterSource({ cellValue }){
      if (cellValue == 'wms') {
          return '手工创建'
        }
        if (cellValue == 'oms') {
          return 'OMS'
        }
        if (cellValue == 'qimen') {
          return '奇门'
        }
        if (cellValue == 'other') {
          return '其他'
        }
    },
    // 单据类型
    formatterType({ cellValue }){
        if (cellValue == '0') {
          return '销售出库'
        }
        if (cellValue == '1') {
          return '破损出库'
        }
        if (cellValue == '2') {
          return '领用出库'
        }
        if (cellValue == '3') {
          return '盈亏出库'
        }
        if (cellValue == '4') {
          return '采购退货'
        }
        if (cellValue == '5') {
          return '调拨出库'
        }
    }
  },
};
</script>
<style scoped>
.container {
  margin: 16px;
}
.inputWidth {
  width: 300px;
}
/* .mytable-footer{
  margin-top: 30px;
} */
/deep/ .vxe-table--render-default .vxe-cell {
  white-space: revert;
}
.btnMarginTop{
  margin-bottom: 10px;
}
/* .btnMargin{
  margin-bottom: 10px;
} */

</style>
